/*
 * test_framework_timer.h
 *
 *  Created on: 2014. 6. 30.
 *      Author: jjaehuny
 */

#ifndef TEST_FRAMEWORK_TIMER_H_
#define TEST_FRAMEWORK_TIMER_H_

#include <memory>

#include <gtest/gtest.h>
#include <glog/logging.h>

#include <Framework/Timer/Handle.h>

class TimeTester
{
public:
	TimeTester() {
		handle_ = ::Framework::Timer::create_handle_multithread();
	}
	~TimeTester() {}

	void Start(int milisecond)
	{
		handle_->SetTimer(milisecond, 1, std::bind(& TimeTester::OnTime, this, std::placeholders::_1, std::placeholders::_2));
	}

	void OnTime(const boost::system::error_code & ec, int id) {
		LOG(INFO) << __PRETTY_FUNCTION__ << "[ID : " << id << "]";
	}

private:
	std::shared_ptr<::Framework::Timer::Handle> handle_;
};

class test_framework_timer : public testing::Test
{
public:
	// Sets up the test fixture.
	virtual void SetUp() {
	}

	// Tears down the test fixture.
	virtual void TearDown() {}
};

TEST_F(test_framework_timer, test_framework_timer)
{
	TimeTester * pTimeTester = new TimeTester;
	pTimeTester->Start(1000);

	//EXPECT_TRUE(false);
}

#endif /* TEST_FRAMEWORK_TIMER_H_ */
